package org.jeecg.modules.demo.crm.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.demo.crm.dto.UserInfoDTO;
import org.jeecg.modules.demo.crm.entity.CWxMsg;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 * @Description: 微信模版消息发送记录
 * @Author: jeecg-boot
 * @Date:   2025-07-26
 * @Version: V1.0
 */
public interface CWxMsgMapper extends BaseMapper<CWxMsg> {


    @Select("SELECT t1.id, t1.username,t3.role_code,t4.open_id from sys_user as t1 LEFT JOIN sys_user_role as t2 ON t1.id = t2.user_id LEFT JOIN sys_role as t3 ON t2.role_id = t3.id  LEFT  JOIN  c_weixin as t4 ON t1.id = t4.user_id  where t1.del_flag = 0 and ( t3.role_code=#{roleCode}  or t3.role_code='admin' )")
    List<UserInfoDTO> queryByOpenId(@Param("roleCode") String roleCode);

    @Select("select * from c_wx_msg where status ='待发送'")
    List<CWxMsg> findByPending();
}
